namespace Akso.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class Add_Classrooms_CodeGroups_Codes : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Basic_Classrooms",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        ClassroomName = c.String(nullable: false, maxLength: 50),
                        Galleryful = c.Int(nullable: false),
                        Remark = c.String(maxLength: 500),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ClassroomEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ClassroomEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Basic_CodeGroups",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CodeGroupName = c.String(nullable: false, maxLength: 50),
                        CodeGroupKey = c.String(nullable: false, maxLength: 50),
                        SortIndex = c.Int(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeGroupEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Basic_Codes",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CodeName = c.String(nullable: false, maxLength: 50),
                        CodeKey = c.String(nullable: false, maxLength: 50),
                        SortIndex = c.Int(nullable: false),
                        CodeGroupID = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Basic_CodeGroups", t => t.CodeGroupID, cascadeDelete: true)
                .Index(t => t.CodeGroupID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Basic_Codes", "CodeGroupID", "dbo.Basic_CodeGroups");
            DropIndex("dbo.Basic_Codes", new[] { "CodeGroupID" });
            DropTable("dbo.Basic_Codes",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Basic_CodeGroups",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CodeGroupEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Basic_Classrooms",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ClassroomEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ClassroomEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
